#encoding = utf-8
import pytest
from python_code.cal import Calculator
import yaml

with open("./datas/cal.yaml") as f:
    datas = yaml.safe_load(f)
    add_data = datas['add']['datas']
    add_myid = datas['add']['myid']
    div_data = datas['div']['datas']
    div_myid = datas['div']['myid']

#@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def cal_config():
    print("开始计算")
    cal = Calculator()
    yield cal
    print("计算结束")


'''
#公共的方法及公共的模块
#pytest自带模块，conftest，命名为conftest

#yield关键字，相当于teardown
@pytest.fixture(scope="session")#相当于setup和teardown的功能，但是比setup和teardown更加灵活
def login():
    print('登录！')
    token = '3wer234234'
    yield token #yield激活了teardown操作
    print('实现登出操作')

@pytest.fixture()
def connDB():
    print('连接数据库')
'''